{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Coding Assignment: Implementation of ANN\n",
    "### Name:    Deepesh Yadav\n",
    "### Roll no:  171380\n",
    "### Batch:    CS-66"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.preprocessing import LabelEncoder,OneHotEncoder\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "import tensorflow as tf\n",
    "from keras.models import Sequential\n",
    "from keras.layers import Dense\n",
    "from sklearn.metrics import confusion_matrix,accuracy_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0.02</th>\n",
       "      <th>0.0371</th>\n",
       "      <th>0.0428</th>\n",
       "      <th>0.0207</th>\n",
       "      <th>0.0954</th>\n",
       "      <th>0.0986</th>\n",
       "      <th>0.1539</th>\n",
       "      <th>0.1601</th>\n",
       "      <th>0.3109</th>\n",
       "      <th>0.2111</th>\n",
       "      <th>...</th>\n",
       "      <th>0.0027</th>\n",
       "      <th>0.0065</th>\n",
       "      <th>0.0159</th>\n",
       "      <th>0.0072</th>\n",
       "      <th>0.0167</th>\n",
       "      <th>0.018</th>\n",
       "      <th>0.0084</th>\n",
       "      <th>0.009</th>\n",
       "      <th>0.0032</th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.0453</td>\n",
       "      <td>0.0523</td>\n",
       "      <td>0.0843</td>\n",
       "      <td>0.0689</td>\n",
       "      <td>0.1183</td>\n",
       "      <td>0.2583</td>\n",
       "      <td>0.2156</td>\n",
       "      <td>0.3481</td>\n",
       "      <td>0.3337</td>\n",
       "      <td>0.2872</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0084</td>\n",
       "      <td>0.0089</td>\n",
       "      <td>0.0048</td>\n",
       "      <td>0.0094</td>\n",
       "      <td>0.0191</td>\n",
       "      <td>0.0140</td>\n",
       "      <td>0.0049</td>\n",
       "      <td>0.0052</td>\n",
       "      <td>0.0044</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.0262</td>\n",
       "      <td>0.0582</td>\n",
       "      <td>0.1099</td>\n",
       "      <td>0.1083</td>\n",
       "      <td>0.0974</td>\n",
       "      <td>0.2280</td>\n",
       "      <td>0.2431</td>\n",
       "      <td>0.3771</td>\n",
       "      <td>0.5598</td>\n",
       "      <td>0.6194</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0232</td>\n",
       "      <td>0.0166</td>\n",
       "      <td>0.0095</td>\n",
       "      <td>0.0180</td>\n",
       "      <td>0.0244</td>\n",
       "      <td>0.0316</td>\n",
       "      <td>0.0164</td>\n",
       "      <td>0.0095</td>\n",
       "      <td>0.0078</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.0100</td>\n",
       "      <td>0.0171</td>\n",
       "      <td>0.0623</td>\n",
       "      <td>0.0205</td>\n",
       "      <td>0.0205</td>\n",
       "      <td>0.0368</td>\n",
       "      <td>0.1098</td>\n",
       "      <td>0.1276</td>\n",
       "      <td>0.0598</td>\n",
       "      <td>0.1264</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0121</td>\n",
       "      <td>0.0036</td>\n",
       "      <td>0.0150</td>\n",
       "      <td>0.0085</td>\n",
       "      <td>0.0073</td>\n",
       "      <td>0.0050</td>\n",
       "      <td>0.0044</td>\n",
       "      <td>0.0040</td>\n",
       "      <td>0.0117</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.0762</td>\n",
       "      <td>0.0666</td>\n",
       "      <td>0.0481</td>\n",
       "      <td>0.0394</td>\n",
       "      <td>0.0590</td>\n",
       "      <td>0.0649</td>\n",
       "      <td>0.1209</td>\n",
       "      <td>0.2467</td>\n",
       "      <td>0.3564</td>\n",
       "      <td>0.4459</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0031</td>\n",
       "      <td>0.0054</td>\n",
       "      <td>0.0105</td>\n",
       "      <td>0.0110</td>\n",
       "      <td>0.0015</td>\n",
       "      <td>0.0072</td>\n",
       "      <td>0.0048</td>\n",
       "      <td>0.0107</td>\n",
       "      <td>0.0094</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.0286</td>\n",
       "      <td>0.0453</td>\n",
       "      <td>0.0277</td>\n",
       "      <td>0.0174</td>\n",
       "      <td>0.0384</td>\n",
       "      <td>0.0990</td>\n",
       "      <td>0.1201</td>\n",
       "      <td>0.1833</td>\n",
       "      <td>0.2105</td>\n",
       "      <td>0.3039</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0045</td>\n",
       "      <td>0.0014</td>\n",
       "      <td>0.0038</td>\n",
       "      <td>0.0013</td>\n",
       "      <td>0.0089</td>\n",
       "      <td>0.0057</td>\n",
       "      <td>0.0027</td>\n",
       "      <td>0.0051</td>\n",
       "      <td>0.0062</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 61 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     0.02  0.0371  0.0428  0.0207  0.0954  0.0986  0.1539  0.1601  0.3109  \\\n",
       "0  0.0453  0.0523  0.0843  0.0689  0.1183  0.2583  0.2156  0.3481  0.3337   \n",
       "1  0.0262  0.0582  0.1099  0.1083  0.0974  0.2280  0.2431  0.3771  0.5598   \n",
       "2  0.0100  0.0171  0.0623  0.0205  0.0205  0.0368  0.1098  0.1276  0.0598   \n",
       "3  0.0762  0.0666  0.0481  0.0394  0.0590  0.0649  0.1209  0.2467  0.3564   \n",
       "4  0.0286  0.0453  0.0277  0.0174  0.0384  0.0990  0.1201  0.1833  0.2105   \n",
       "\n",
       "   0.2111  ...  0.0027  0.0065  0.0159  0.0072  0.0167   0.018  0.0084  \\\n",
       "0  0.2872  ...  0.0084  0.0089  0.0048  0.0094  0.0191  0.0140  0.0049   \n",
       "1  0.6194  ...  0.0232  0.0166  0.0095  0.0180  0.0244  0.0316  0.0164   \n",
       "2  0.1264  ...  0.0121  0.0036  0.0150  0.0085  0.0073  0.0050  0.0044   \n",
       "3  0.4459  ...  0.0031  0.0054  0.0105  0.0110  0.0015  0.0072  0.0048   \n",
       "4  0.3039  ...  0.0045  0.0014  0.0038  0.0013  0.0089  0.0057  0.0027   \n",
       "\n",
       "    0.009  0.0032  0  \n",
       "0  0.0052  0.0044  0  \n",
       "1  0.0095  0.0078  0  \n",
       "2  0.0040  0.0117  0  \n",
       "3  0.0107  0.0094  0  \n",
       "4  0.0051  0.0062  0  \n",
       "\n",
       "[5 rows x 61 columns]"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#importing dataset\n",
    "df = pd.read_csv('sonar-all-data.csv')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [],
   "source": [
    "#spliting data into features and labels\n",
    "X = df.iloc[:,0:60]  #features\n",
    "Y = df.iloc[:,60:61]  #labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [],
   "source": [
    "#splitting dataset into training and testing data\n",
    "\n",
    "x_train,x_test,y_train,y_test = train_test_split(X,Y,test_size = 0.2,random_state = 3)  \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [],
   "source": [
    "clf = Sequential()\n",
    "clf.add(Dense(input_dim=60,units=31,kernel_initializer= 'uniform', activation ='relu'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [],
   "source": [
    "clf.add(Dense(units=31,activation ='relu',kernel_initializer ='uniform'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [],
   "source": [
    "clf.add(Dense(units =1,kernel_initializer='uniform',activation='relu'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [],
   "source": [
    "clf.compile(optimizer ='adam',loss='binary_crossentropy',metrics = ['accuracy'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/100\n",
      "165/165 [==============================] - 0s 577us/step - loss: 2.1435 - accuracy: 0.4667\n",
      "Epoch 2/100\n",
      "165/165 [==============================] - 0s 85us/step - loss: 1.3092 - accuracy: 0.4667\n",
      "Epoch 3/100\n",
      "165/165 [==============================] - 0s 89us/step - loss: 0.9134 - accuracy: 0.4667\n",
      "Epoch 4/100\n",
      "165/165 [==============================] - 0s 92us/step - loss: 0.7202 - accuracy: 0.4848\n",
      "Epoch 5/100\n",
      "165/165 [==============================] - 0s 88us/step - loss: 0.6734 - accuracy: 0.5758\n",
      "Epoch 6/100\n",
      "165/165 [==============================] - 0s 87us/step - loss: 0.6662 - accuracy: 0.6242\n",
      "Epoch 7/100\n",
      "165/165 [==============================] - 0s 77us/step - loss: 0.6591 - accuracy: 0.6000\n",
      "Epoch 8/100\n",
      "165/165 [==============================] - 0s 87us/step - loss: 0.6543 - accuracy: 0.6242\n",
      "Epoch 9/100\n",
      "165/165 [==============================] - 0s 87us/step - loss: 0.6511 - accuracy: 0.6424\n",
      "Epoch 10/100\n",
      "165/165 [==============================] - 0s 86us/step - loss: 0.6398 - accuracy: 0.6788\n",
      "Epoch 11/100\n",
      "165/165 [==============================] - 0s 81us/step - loss: 0.6341 - accuracy: 0.6606\n",
      "Epoch 12/100\n",
      "165/165 [==============================] - 0s 82us/step - loss: 0.6220 - accuracy: 0.7091\n",
      "Epoch 13/100\n",
      "165/165 [==============================] - 0s 83us/step - loss: 0.6119 - accuracy: 0.7394\n",
      "Epoch 14/100\n",
      "165/165 [==============================] - 0s 78us/step - loss: 0.6015 - accuracy: 0.7212\n",
      "Epoch 15/100\n",
      "165/165 [==============================] - 0s 77us/step - loss: 0.5943 - accuracy: 0.7152\n",
      "Epoch 16/100\n",
      "165/165 [==============================] - 0s 75us/step - loss: 0.5762 - accuracy: 0.7394\n",
      "Epoch 17/100\n",
      "165/165 [==============================] - 0s 82us/step - loss: 0.5668 - accuracy: 0.7576\n",
      "Epoch 18/100\n",
      "165/165 [==============================] - 0s 80us/step - loss: 0.5472 - accuracy: 0.7273\n",
      "Epoch 19/100\n",
      "165/165 [==============================] - 0s 83us/step - loss: 0.5319 - accuracy: 0.7515\n",
      "Epoch 20/100\n",
      "165/165 [==============================] - 0s 91us/step - loss: 0.5177 - accuracy: 0.7455\n",
      "Epoch 21/100\n",
      "165/165 [==============================] - 0s 84us/step - loss: 0.5034 - accuracy: 0.7697\n",
      "Epoch 22/100\n",
      "165/165 [==============================] - 0s 77us/step - loss: 0.4872 - accuracy: 0.8061\n",
      "Epoch 23/100\n",
      "165/165 [==============================] - 0s 79us/step - loss: 0.4787 - accuracy: 0.7697\n",
      "Epoch 24/100\n",
      "165/165 [==============================] - 0s 78us/step - loss: 0.4629 - accuracy: 0.8121\n",
      "Epoch 25/100\n",
      "165/165 [==============================] - 0s 86us/step - loss: 0.4545 - accuracy: 0.7758\n",
      "Epoch 26/100\n",
      "165/165 [==============================] - 0s 83us/step - loss: 0.4504 - accuracy: 0.7818\n",
      "Epoch 27/100\n",
      "165/165 [==============================] - 0s 89us/step - loss: 0.4342 - accuracy: 0.8242\n",
      "Epoch 28/100\n",
      "165/165 [==============================] - 0s 86us/step - loss: 0.4280 - accuracy: 0.8121\n",
      "Epoch 29/100\n",
      "165/165 [==============================] - 0s 87us/step - loss: 0.4246 - accuracy: 0.8061\n",
      "Epoch 30/100\n",
      "165/165 [==============================] - 0s 85us/step - loss: 0.4269 - accuracy: 0.8121\n",
      "Epoch 31/100\n",
      "165/165 [==============================] - 0s 107us/step - loss: 0.4110 - accuracy: 0.8303\n",
      "Epoch 32/100\n",
      "165/165 [==============================] - 0s 80us/step - loss: 0.3988 - accuracy: 0.8424\n",
      "Epoch 33/100\n",
      "165/165 [==============================] - 0s 70us/step - loss: 0.4809 - accuracy: 0.8121\n",
      "Epoch 34/100\n",
      "165/165 [==============================] - 0s 67us/step - loss: 0.4012 - accuracy: 0.7818\n",
      "Epoch 35/100\n",
      "165/165 [==============================] - 0s 77us/step - loss: 0.5627 - accuracy: 0.7394\n",
      "Epoch 36/100\n",
      "165/165 [==============================] - 0s 74us/step - loss: 0.3981 - accuracy: 0.7879\n",
      "Epoch 37/100\n",
      "165/165 [==============================] - 0s 70us/step - loss: 0.4012 - accuracy: 0.8061\n",
      "Epoch 38/100\n",
      "165/165 [==============================] - 0s 70us/step - loss: 0.4259 - accuracy: 0.8061\n",
      "Epoch 39/100\n",
      "165/165 [==============================] - 0s 89us/step - loss: 0.3871 - accuracy: 0.8182\n",
      "Epoch 40/100\n",
      "165/165 [==============================] - 0s 94us/step - loss: 0.3755 - accuracy: 0.8485\n",
      "Epoch 41/100\n",
      "165/165 [==============================] - 0s 78us/step - loss: 0.3762 - accuracy: 0.8303\n",
      "Epoch 42/100\n",
      "165/165 [==============================] - 0s 81us/step - loss: 0.3718 - accuracy: 0.8545\n",
      "Epoch 43/100\n",
      "165/165 [==============================] - 0s 84us/step - loss: 0.3661 - accuracy: 0.8545\n",
      "Epoch 44/100\n",
      "165/165 [==============================] - 0s 74us/step - loss: 0.3643 - accuracy: 0.8485\n",
      "Epoch 45/100\n",
      "165/165 [==============================] - 0s 85us/step - loss: 0.3629 - accuracy: 0.8606\n",
      "Epoch 46/100\n",
      "165/165 [==============================] - 0s 68us/step - loss: 0.3566 - accuracy: 0.8545\n",
      "Epoch 47/100\n",
      "165/165 [==============================] - 0s 80us/step - loss: 0.3688 - accuracy: 0.8242\n",
      "Epoch 48/100\n",
      "165/165 [==============================] - 0s 89us/step - loss: 0.3638 - accuracy: 0.8182\n",
      "Epoch 49/100\n",
      "165/165 [==============================] - 0s 81us/step - loss: 0.3604 - accuracy: 0.8424\n",
      "Epoch 50/100\n",
      "165/165 [==============================] - 0s 77us/step - loss: 0.3499 - accuracy: 0.8121\n",
      "Epoch 51/100\n",
      "165/165 [==============================] - 0s 74us/step - loss: 0.3478 - accuracy: 0.8727\n",
      "Epoch 52/100\n",
      "165/165 [==============================] - 0s 76us/step - loss: 0.3414 - accuracy: 0.8485\n",
      "Epoch 53/100\n",
      "165/165 [==============================] - 0s 92us/step - loss: 0.3447 - accuracy: 0.8606\n",
      "Epoch 54/100\n",
      "165/165 [==============================] - 0s 93us/step - loss: 0.3416 - accuracy: 0.8121\n",
      "Epoch 55/100\n",
      "165/165 [==============================] - 0s 78us/step - loss: 0.3334 - accuracy: 0.8606\n",
      "Epoch 56/100\n",
      "165/165 [==============================] - 0s 79us/step - loss: 0.3357 - accuracy: 0.8485\n",
      "Epoch 57/100\n",
      "165/165 [==============================] - 0s 79us/step - loss: 0.3311 - accuracy: 0.8242\n",
      "Epoch 58/100\n",
      "165/165 [==============================] - 0s 79us/step - loss: 0.3271 - accuracy: 0.8303\n",
      "Epoch 59/100\n",
      "165/165 [==============================] - 0s 76us/step - loss: 0.3437 - accuracy: 0.8485\n",
      "Epoch 60/100\n",
      "165/165 [==============================] - 0s 71us/step - loss: 0.3326 - accuracy: 0.8242\n",
      "Epoch 61/100\n",
      "165/165 [==============================] - 0s 76us/step - loss: 0.3272 - accuracy: 0.8364\n",
      "Epoch 62/100\n",
      "165/165 [==============================] - 0s 79us/step - loss: 0.3298 - accuracy: 0.8424\n",
      "Epoch 63/100\n",
      "165/165 [==============================] - 0s 82us/step - loss: 0.3176 - accuracy: 0.7939\n",
      "Epoch 64/100\n",
      "165/165 [==============================] - 0s 74us/step - loss: 0.3266 - accuracy: 0.8667\n",
      "Epoch 65/100\n",
      "165/165 [==============================] - 0s 75us/step - loss: 0.3090 - accuracy: 0.8182\n",
      "Epoch 66/100\n",
      "165/165 [==============================] - 0s 73us/step - loss: 0.3143 - accuracy: 0.8485\n",
      "Epoch 67/100\n",
      "165/165 [==============================] - 0s 78us/step - loss: 0.3030 - accuracy: 0.8545\n",
      "Epoch 68/100\n",
      "165/165 [==============================] - 0s 75us/step - loss: 0.3038 - accuracy: 0.8121\n",
      "Epoch 69/100\n",
      "165/165 [==============================] - 0s 70us/step - loss: 0.3035 - accuracy: 0.8545\n",
      "Epoch 70/100\n",
      "165/165 [==============================] - 0s 72us/step - loss: 0.2991 - accuracy: 0.8182\n",
      "Epoch 71/100\n",
      "165/165 [==============================] - 0s 77us/step - loss: 0.2937 - accuracy: 0.8424\n",
      "Epoch 72/100\n",
      "165/165 [==============================] - 0s 77us/step - loss: 0.2978 - accuracy: 0.7879\n",
      "Epoch 73/100\n",
      "165/165 [==============================] - 0s 79us/step - loss: 0.2976 - accuracy: 0.8545\n",
      "Epoch 74/100\n",
      "165/165 [==============================] - 0s 72us/step - loss: 0.2869 - accuracy: 0.8182\n",
      "Epoch 75/100\n",
      "165/165 [==============================] - 0s 74us/step - loss: 0.2903 - accuracy: 0.8303\n",
      "Epoch 76/100\n",
      "165/165 [==============================] - 0s 77us/step - loss: 0.2803 - accuracy: 0.8303\n",
      "Epoch 77/100\n",
      "165/165 [==============================] - 0s 80us/step - loss: 0.2786 - accuracy: 0.8061\n",
      "Epoch 78/100\n",
      "165/165 [==============================] - 0s 89us/step - loss: 0.2868 - accuracy: 0.7758\n",
      "Epoch 79/100\n",
      "165/165 [==============================] - 0s 79us/step - loss: 0.2838 - accuracy: 0.7939\n",
      "Epoch 80/100\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "165/165 [==============================] - 0s 75us/step - loss: 0.2948 - accuracy: 0.8000\n",
      "Epoch 81/100\n",
      "165/165 [==============================] - 0s 78us/step - loss: 0.3089 - accuracy: 0.7818\n",
      "Epoch 82/100\n",
      "165/165 [==============================] - 0s 82us/step - loss: 0.2820 - accuracy: 0.8121\n",
      "Epoch 83/100\n",
      "165/165 [==============================] - 0s 75us/step - loss: 0.2705 - accuracy: 0.8424\n",
      "Epoch 84/100\n",
      "165/165 [==============================] - 0s 73us/step - loss: 0.2702 - accuracy: 0.7879\n",
      "Epoch 85/100\n",
      "165/165 [==============================] - 0s 72us/step - loss: 0.2667 - accuracy: 0.8061\n",
      "Epoch 86/100\n",
      "165/165 [==============================] - 0s 78us/step - loss: 0.2895 - accuracy: 0.7939\n",
      "Epoch 87/100\n",
      "165/165 [==============================] - 0s 70us/step - loss: 0.2633 - accuracy: 0.8121\n",
      "Epoch 88/100\n",
      "165/165 [==============================] - 0s 75us/step - loss: 0.2586 - accuracy: 0.8121\n",
      "Epoch 89/100\n",
      "165/165 [==============================] - 0s 76us/step - loss: 0.2625 - accuracy: 0.8121\n",
      "Epoch 90/100\n",
      "165/165 [==============================] - 0s 76us/step - loss: 0.2544 - accuracy: 0.8182\n",
      "Epoch 91/100\n",
      "165/165 [==============================] - 0s 79us/step - loss: 0.2536 - accuracy: 0.7939\n",
      "Epoch 92/100\n",
      "165/165 [==============================] - 0s 71us/step - loss: 0.2508 - accuracy: 0.8000\n",
      "Epoch 93/100\n",
      "165/165 [==============================] - 0s 77us/step - loss: 0.2433 - accuracy: 0.8242\n",
      "Epoch 94/100\n",
      "165/165 [==============================] - 0s 72us/step - loss: 0.2427 - accuracy: 0.7818\n",
      "Epoch 95/100\n",
      "165/165 [==============================] - 0s 75us/step - loss: 0.9346 - accuracy: 0.7273\n",
      "Epoch 96/100\n",
      "165/165 [==============================] - 0s 72us/step - loss: 0.4372 - accuracy: 0.7758\n",
      "Epoch 97/100\n",
      "165/165 [==============================] - 0s 74us/step - loss: 0.2773 - accuracy: 0.7818\n",
      "Epoch 98/100\n",
      "165/165 [==============================] - 0s 79us/step - loss: 0.2407 - accuracy: 0.8545\n",
      "Epoch 99/100\n",
      "165/165 [==============================] - 0s 76us/step - loss: 0.2333 - accuracy: 0.8121\n",
      "Epoch 100/100\n",
      "165/165 [==============================] - 0s 78us/step - loss: 0.2345 - accuracy: 0.7939\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.callbacks.callbacks.History at 0x7f434c67f250>"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf.fit(x_train,y_train,batch_size=10,epochs = 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [],
   "source": [
    "pred = clf.predict(x_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[13  6  0]\n",
      " [ 3 18  2]\n",
      " [ 0  0  0]]\n"
     ]
    }
   ],
   "source": [
    "cm = confusion_matrix(y_test,pred.round())\n",
    "print(cm)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy using an ANN : 0.7380952380952381\n"
     ]
    }
   ],
   "source": [
    "print('Accuracy using an ANN :',accuracy_score(y_test, pred.round()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
